package com.example.aop.proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.invoke.MethodHandleInfo;
import java.lang.reflect.Method;

/**
 * ClassName: CGLibIntercepter
 * Package: IntelliJ IDEA
 * Description:
 *
 * @Author 谷京京
 * @Create 2024/2/27 17:05
 * @Version 1.0
 */
public class CGLibIntercepter implements MethodInterceptor {

    //被代理的对象
    private Object target;
    public CGLibIntercepter(Object target) {
        this.target = target;
    }
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("CGL开始代理");
        Object result = methodProxy.invoke(target, objects);
        System.out.println("CGL结束代理");
        return result;
    }
}
